`timescale 1ns / 1ps
module aestop_tb;
//有问题，写入数据不行
wire [31:0] dout;
reg [31:0] din;
reg clk,rst,staenc,stadec,load_shift,loadkey;

aestop aestop(clk,rst,staenc,stadec,load_shift,loadkey,din,dout);

//clock generation				   
initial clk = 1;
always #10 clk = ~clk;
	
initial 
	begin		     	
		    rst=1;
		    staenc=0;
		    stadec=0;
		    load_shift=0;
		    loadkey=0;
		#4  rst=0;		//test reset
		#40 rst=1;
		    loadkey=1;//load cipher key 
		    din=32'h09cf4f3C;                         
  		
  		#20 loadkey=1; 
		    din=32'habf71588;
		
		#20 loadkey=1; 
		    din=32'h28aed2a6;
	
		#20 loadkey=1; 
		    din=32'h2b7e1516;

		#20 loadkey=0;
		    load_shift=1;//load plain text 
		    din=32'he0370734;
	       
    #20 load_shift=1;
        din=32'h313198a2;

    #20 load_shift=1;
        din=32'h885a308d;
         
    #20 load_shift=1;
        din=32'h3243f6a8;

    #20 load_shift=0;
        staenc=1; //start encryption
		#20 staenc=0;
		
		#260 load_shift=1;//shift right to output cipher text 
		#300  load_shift=0;//stop shift right
		
		#100  load_shift=1;//load cipher text 
		     din=32'h196a0b32;         
        
    #20  load_shift=1;
         din=32'hdc118597;

    #20  load_shift=1;
         din=32'h02dc09fb;
         
    #20  load_shift=1;
         din=32'h3925841d;

  		#20  load_shift=0;
         stadec=1; //start decryption
		#20  stadec=0;
		
		#260 load_shift=1;//shift right to output plain text 
		#300  load_shift=0; //stop shift right
  		    		
		#100 $finish;		
	end
	
		  
	  	//initial begin
		//#500000000  $finish;
  
       //	end
  
	initial begin
	$fsdbDumpfile("wave.fsdb");
	$fsdbDumpvars            ;
	$fsdbDumpMDA             ;
	end
endmodule
